<?php
/**
 * Created by PhpStorm.
 * User: luanalex
 * Date: 2017/9/18
 * Time: 11:31
 */

?>

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-type" content="text/html">
    <meta charset="UTF-8">
    <meta content="always" name="referrer">
    <meta name="theme-color" content="#2932e1">

    <script type="text/javascript" src="/sktenproject/learning/bannerslider/js/imageflow.js"></script>
    <link type="text/css" rel="Stylesheet" href="/sktenproject/learning/bannerslider/css/imageflow.css" />

    <link href="../home/style/homecss.css" rel="stylesheet"/>
    <style type="text/css">
        body {
            display: block;
            align-items: flex-start;
            margin-top: 0px;
            margin-left: 0px;
            margin-right: 0px;
            background-color: aliceblue;
            width: 100%;
            height: 500px;
            link = "#ff0000" alink = "#ff0000" vlink = "#ff0000"
        }
        *{
            margin: 0px ;
            padding: 0px ;
        }
        #layout{
            width: 960px ;
            margin: 0 auto ;
        }
        #banner{
            display:flex;
            flex-direction: row;
            position: relative;
            overflow: hidden;
            width: 600px;
            height: 200px;
            border-radius: 10px ;
            border: 2px solid black;
        }
        #banner_img {
            display: flex;
            flex-direction: row;
            width: 100%;
            height: 100%;
        }
        #banner_img li{
            display:flex;
            flex-direction: row;
            justify-content: space-around;
            width: 600px;
            float: left;
            list-style-type: none;

        }
        #index{
            position: absolute;
            right: 8px ;
            bottom: 8px ;
        }
        #index li{
            float: left;
            width: 160px ;
            height: 16px ;
            text-align: center;
            line-height: 16px ;
            border-radius: 5px ;
            border:1px solid #FF7300 ;
            background: white;
            list-style: none;
            margin-left: 8px ;
            cursor: pointer;
        }
        .clearfix:after{
            content: "" ;
            height: 0px ;
            display: block;
            clear:both ;
        }
        .on
        {
            background:#FF7300 ;
        }
    </style>
    <title>十户香</title>
</head>

<body>
<div id="LoopDiv">
    <input id="S_Num" type="hidden" value="8" />
    <div id="starsIF" class="imageflow">
        <img src="images/1.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/2.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/1.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/3.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/4.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/5.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/6.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/1.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/2.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/3.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/4.png" longdesc="#" width="280" height="300" alt="Picture" />
        <img src="images/5.png" longdesc="#" width="280" height="300" alt="Picture" />
    </div>
</div>
<div class="clear"></div>
</body>
</html>

<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
init();
function init()
{
    $(function(){
        var index = 0 ;
        var adTime ;
        var len = $("#banner_img li").length ;
        addIndex(len) ;
        var bannerLi = $("#index li");
        //handle index
        $("#index li").mouseover(function() {
            index = $("#index li").index(this) ;
            showImgs(index) ;
        });
        //toggleInterval
        $("#banner").hover(function(){
            clearInterval(adTimer);
        },function(){
            adTimer=setInterval(function(){
                //alert(index) ;
                showImgs(index);
                index++;
                if(index==len){
                    index=0;
                }
            },2000)
        }).trigger('mouseleave');
    });
}
//auto add index
function addIndex(n)
{
    var ul = $("<ul id=\"index\"></ul>") ;
    for(var i=1;i<=n;i++)
    {
        var li = $("<li></li>") ;
        li.append(function(num){
            return num
            }(i)) ;
        ul.append(li) ;
    }
    ul.children().first().addClass('on') ;
    $("#banner_img").append(ul);
}
function showImgs(index)
{
    var len = $("#banner_img li").length ;
    var adwidth=$("#banner_img>li:first").width();
    $("#banner_img").stop(true, false) ;
    //$("#banner_img").css('margin-left', -index*adwidth+"px");
    if (index == len-1) {
        alert(index,"--asdfa--",len);
        $("#banner_img").style.marginLeft = 0px;
//        $("#banner_img").animate({
            "marginLeft":-adwidth*index+"px"
//        },0);
    }else{
        $("#banner_img").animate({
            "marginLeft":-adwidth*index+"px"
        },1000);
    }

    $("#index li").removeClass('on').eq(index).addClass('on') ;
}
</script>
